//////////////////////////////////////////////////////////////////////////////////
//	 Copyright 2011 by Yosef Grabivker, ryuho@homenetworksoft.com
//
//   Licensed under the Apache License, Version 2.0 (the "License");
//   you may not use this file except in compliance with the License.
//   You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
//   Unless required by applicable law or agreed to in writing, software
//   distributed under the License is distributed on an "AS IS" BASIS,
//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//   See the License for the specific language governing permissions and
//   limitations under the License.
//////////////////////////////////////////////////////////////////////////////////

#ifndef _LINUX_SHELL_CMD_PROC_YG_H__
#define _LINUX_SHELL_CMD_PROC_YG_H__

#include "shellcmdprocessor.h"
#include "def.h"

class CLinuxShellCmdProcessor: public CShellCmdProcessor
{
public:
							CLinuxShellCmdProcessor(CLinkGuard&	link);
	virtual					~CLinuxShellCmdProcessor();
	virtual void			DispatchCmd(const COMMANDREQUEST& cmd, COMMANDRESPONSE& cmdOut,	bool& bNotify);
	virtual void			Initialize();
	virtual RTSTRING		GetCaps();

protected:
	void					OnGetConntracMax(COMMANDRESPONSE& cmdOut, bool& bNotify);
	void					OnGetSlabTable(COMMANDRESPONSE& cmdOut, bool& bNotify);
	void					OnGetMemMax(COMMANDRESPONSE& cmdOut, bool& bNotify);
	void					OnGetMemCur(COMMANDRESPONSE& cmdOut, bool& bNotify);
	void					OnGetRTCacheMax(COMMANDRESPONSE& cmdOut, bool& bNotify);
	void					OnGetRTCacheVal(COMMANDRESPONSE& cmdOut, bool& bNotify);
	void					OnGetCPU(COMMANDRESPONSE& cmdOut, bool& bNotify);
	void					OnExecuteScript(const wxString& strScript, COMMANDRESPONSE& cmdOut, bool& bNotify);
	void					OnGetConntracTableEnt(COMMANDRESPONSE& cmdOut, bool& bNotify);
	void					OnGetInterfaceStat(COMMANDRESPONSE& cmdOut, bool& bNotify);
	void					OnGetARPTable(COMMANDRESPONSE& cmdOut, bool& bNotify);
	void					OnGetIpConfig(COMMANDRESPONSE& cmdOut, bool& bNotify);
	void					OnGetRoutingTable(COMMANDRESPONSE& cmdOut, bool& bNotify);
	void					OnGetRouterWANAddress( const RTSTRING& strIPTable, const RTSTRING& strRoutingTable, COMMANDRESPONSE& cmdOut, bool& bNotify);
	void					OnGetRouterID(COMMANDRESPONSE& cmdOut, bool& bNotify);
	void					OnGetTCPTimeOuts(COMMANDRESPONSE& cmdOut, bool& bNotify);
	void					OnGetVersion(COMMANDRESPONSE& cmdOut, bool& bNotify);
	void					OnFlushRTTable(COMMANDRESPONSE& cmdOut, bool& bNotify);
	void					OnPing(const wxString& strScript, COMMANDRESPONSE& cmdOut, bool& bNotify);
	void					OnGetProcList(COMMANDRESPONSE& cmdOut, bool& bNotify);


protected:
	long					ReadNumberProc(const wxString& strPath);
	long 					ReadLinesProc(const wxString& strPath, RTSTRING& strData );
	long					ReadNumberProcFromLine(const wxString& strPath, const RTSTRING& strVal);

	void					SendActionToRouter(const wxString& str);

private:
	//Parse NAT table helpers
	bool					ParseEntry( const char* szEntry, CONNTRACENTRY& entry );
	bool					ParseToken( const char* szToken, CONNTRACENTRY& entry );


private:
	CLinkGuard&				m_link;
	bool					m_bGrepSupported;
	long long 				u_,n_,s_,i_,w_,x_,y_,z_,tot_frme_;

};
#endif //_LINUX_SHELL_CMD_PROC_YG_H__